/**
 * Test Class - IOSystemTests.
 * Boundary Conditions (Low, Middle, High, Null, 
 * Empty, Valid, Correct, Duplicates and more).
 * Tests use methods such as assertEquals, assertTrue, assertFalse.
 * 
 * @author ct267, msm41, sg350.
 */
package tests;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.TreeSet;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import restaurant.IOsystem;
import restaurant.MenuItem;
import restaurant.OrderItem;

public class IOsystemTests {

	private TreeSet<MenuItem> menuTreeSet = null;
	private ArrayList<OrderItem> orderList = null;
	private IOsystem io = null;

	@Before
	public void setUp() {
		// Initialises test parameters.
		io = new IOsystem();
		menuTreeSet = new TreeSet<MenuItem>();
		orderList = new ArrayList<OrderItem>();
	}

	@After
	public void tearDown() {
		// Clean up resources.
		menuTreeSet.clear();
		orderList.clear();
		menuTreeSet = null;
		orderList = null;
		io = null;
	}

	// menu_input.txt////////////////////////////////////////

	/**
	 * Test with no file.
	 * */
	@Test
	public void readOrderUndefinedFile() {
		// Check that FileNotFound is handled.
		menuTreeSet.clear();
		menuTreeSet = io.readMenuFile("");
		assertEquals(0, menuTreeSet.size());
	}
	
	/**
	 * Test with valid menu file.
	 * */
	@Test
	public void readMenuValidFile() {
		// Check menuTreeSet contains initialised 19 items.
		try{
		menuTreeSet.clear();
		menuTreeSet = io.readMenuFile("menu_input.txt");
		assertEquals(19, menuTreeSet.size());
		}catch(Exception e){}
	}
	
	/**
	 * Test with valid order file.
	 * */
	@Test
	public void readOrderValidFile() {
		// Check orderList contains initialised 20 orders.
		try{
		orderList.clear();
		orderList = io.readOrderFile("order_input.txt");
		assertEquals(19, orderList.size());
	}catch(Exception e){}
		}
	
	/**
	 * Test with empty string as file
	 * 
	@Test(expected = Exception.class)
	public void readEmptyStringFile() {
		menuTreeSet.clear();
		menuTreeSet = io.readMenuFile("");
	}
*/
	
	/**
	 * Test Read orderList from invalid file. Expect Exception.
	 * 
	@Test(expected = Exception.class)
	public void readOrderInvalidFile() {
		// Check that invalid text from menu_input.txt handled.
		orderList.clear();
		orderList = io.readOrderFile("menu_input.txt");
	}
*/
	
	

}